package bingo.portal.action;

import java.io.IOException;

import javax.servlet.ServletException;

import net.bingosoft.common.struts.ActionContext;
import bingo.common.annotation.Autowire;
import bingo.common.annotation.BeanDefination;
import bingo.portal.model.Portal;
import bingo.portal.service.IPortalManager;

/**
 * Mar 3, 2009 2:35:23 PM PortalManageAction.java
 * Author:yangdongyu(yangdy@bingosoft.net)
 * ReadMe:
 * ChangeLog:
 */
@BeanDefination("portal")
public class PortalManageAction {
	@Autowire
	private IPortalManager portalManager;


	public void index() throws ServletException, IOException{
		Portal portal = new Portal();
		//获取当前登录人
		String princial = portalManager.getPrincial();
		//获取当前Portal的配置信息
		portal.setConfiguration(portalManager.getConfiguration());
		//获取主菜单
		portal.setMenuList(portalManager.getMainMenuList(princial));
		//设置当前登录人
		ActionContext.setRequestAttribute("princial", princial);
		//设置Portal信息
		ActionContext.setRequestAttribute("portal", portal);
		//转向到Portal 页面
		ActionContext.forward("/portal/layout/portal.jsp");
	}
	
	/**
	 * 获取子菜单信息
	 * @param parentMenuId
	 * @throws IOException 
	 * @throws ServletException 
	 */
	public void menu(String parentMenuId) throws ServletException, IOException{
		//获取当前登录人
		String princial = portalManager.getPrincial();
		//设置Portal信息
		ActionContext.setRequestAttribute("menuList", portalManager.getChildMenus(princial, parentMenuId));
		//转向到Portal 页面
		ActionContext.forward("/portal/layout/menu.jsp");
	}

	public IPortalManager getPortalManager() {
		return portalManager;
	}

	public void setPortalManager(IPortalManager portalManager) {
		this.portalManager = portalManager;
	}
	

}
